package com.hiro.framework.tilegame.controller;

import javax.swing.JOptionPane;

import com.egghiro.framework.j2se.game.core.SGSystem;
import com.hiro.framework.tilegame.controller.system.STileGameSystem;
import com.hiro.framework.tilegame.model.actor.ITileBoard;

public class GameOverState extends GameState {

    private static GameOverState instance;
    private static byte[] lock = new byte[0];

    public GameOverState(ITileBoard tileBoard) {
        super(tileBoard);

    }

    public static GameOverState getInstance(ITileBoard tileBoard) {
        if (instance == null || instance.equals(tileBoard) == false) {
            synchronized (lock) {
                if (instance == null || instance.equals(tileBoard) == false) {
                    instance = new GameOverState(tileBoard);
                }
            }
        }
        return instance;
    }

    public void showGameOverDialog() {
        switch ( STileGameSystem.getInstance().showMessage("Game Over...\nOne more Game?", "Game Over", JOptionPane.OK_CANCEL_OPTION)) {
        case JOptionPane.OK_OPTION:
//            canvas.setState(GameStartState.getInstance(canvas, tileBoard));
            STileGameSystem.getInstance().restart();
            break;
        default:
            SGSystem.exit();
            break;
        }
    }


}
